import Reflux from "reflux"
import GUtils from "@/utils";
import BaseAction from "@/base/BaseAction";
import {addDefaultListerns} from "../../../base/BaseAction";

const prefix ="/balance/shopBalance/";
const withdrawalPrefix ="/balance/shopWithdrawal/";
const api = {
    search: prefix+"search",
    create: prefix+"create",
    edit: prefix+"edit",
    detail:  prefix+"detail",
    getData: prefix+"getPlatformDataV2",

    createWithdrawal: withdrawalPrefix+"create",
};

const createAction = () => {
    const Action = Reflux.createActions({
        ...BaseAction,
        getData:{asyncResult: true},

        preCreateWithdrawal:{},
        createWithdrawal:{asyncResult: true}

    });

    addDefaultListerns(Action, api);
    Action.getData.listen(function (so) {
        GUtils.jsonAjax.post(api.getData, so).then(this.completed, this.failed);
    });

    Action.createWithdrawal.listen(function (vo, callback) {
        GUtils.jsonAjax.post(api.createWithdrawal, vo).then(this.completed.bind(this,callback), this.failed);
    });


    return Action;
};

export {api, createAction}